import { Component, OnInit } from '@angular/core';
import {DynamicDialogConfig, DynamicDialogRef} from "primeng/api";
import {News} from "../../model/News";

@Component({
  selector: 'app-newsedit',
  templateUrl: './newsedit.component.html',
  styleUrls: ['./newsedit.component.css']
})
export class NewseditComponent implements OnInit {

  news:News;

  constructor(public ref: DynamicDialogRef, public config: DynamicDialogConfig) {
    this.news=new News();
  }

  ngOnInit() {

    //不为空，则执行修改操作
    if(this.config.data){
      this.news=new News();
      this.news=this.config.data.news;
    }
    else{
      this.news=new News();
    }




  }

  save(){
    //console.dir(this.news);

    this.closeDialog();

  }

  closeDialog(){

    this.ref.close(this.news);

  }

}
